package com.study.hot.jetpack.room.test_address.db

import androidx.paging.DataSource
import androidx.room.*

/**
 * <pre>
 *     author : fauks
 *     time   : 2020/03/25
 *     desc   :
 * </pre>
 */
@Dao
interface AddressDao {

    @Insert
    fun insert(vararg addressBean: Address)

    @Update
    fun update(vararg addressBean: Address)

    @Delete
    fun delete(vararg addressBean: Address)

    @Query("SELECT * FROM Address")
    fun getAddress(): MutableList<Address>

    @Query("DELETE FROM Address")
    fun deleteAll()

    //返回Paging需要的数据
    @Query("SELECT * FROM Address")
    fun getAddressForPage(): DataSource.Factory<Int, Address>
}